#!/usr/bin/env python

__author__ = 'blogporter@gmail.com'

import metaweblog 
from policy import Policy
from datetime import datetime

class BlogbusProvider:
#http://username.blogbus.com/api
    def __init__(self, user_name, password):
        self.user_name = user_name
        self.password = password

#class LiveSpaceProvider(metaweblog.MetaWeblogProvider):
##http://msdn.microsoft.com/en-us/library/bb259698.aspx
## api reference:  http://msdn.microsoft.com/en-us/library/bb259697.aspx
## c# example:   http://msdn.microsoft.com/en-us/library/aa905670.aspx 
## live space rss: blog feeds:   http://msdn.microsoft.com/en-us/library/bb447761.aspx
## note: MAX_POSTS_NUM for live space is 20, otherwise, the server returns error
#
## http://rxwencoder.spaces.live.com/
#    def __init__(self, user_name, password):
#        super(LiveSpaceProvider, self).__init__("https://storage.msn.com/storageservice/MetaWeblog.rpc", user_name, password, use_datetime=False)
#
#    def GetPosts(self, max_posts_num = 19, start_date = datetime.min.replace(year=1900), end_date = datetime.max):
#        return super(LiveSpaceProvider, self).GetPosts(max_posts_num, start_date, end_date)

class CnblogsProvider(metaweblog.MetaWeblogProvider):
    #http://www.cnblogs.com/rxwen/services/metaweblog.aspx
    # cnblogs doesn't allow us specify post create time
    def __init__(self, user_name, password):
        super(CnblogsProvider, self).__init__("http://www.cnblogs.com/%s/services/metaweblog.aspx"%user_name, user_name, password)

class WordpressProvider(metaweblog.MetaWeblogProvider):
    def __init__(self, user_name, password):
        super(WordpressProvider, self).__init__("http://%s.wordpress.com/xmlrpc.php"%user_name, user_name, password)

class CsdnProvider(metaweblog.MetaWeblogProvider):
    #http://blog.csdn.net/rx_wen/services/metablogapi.aspx
    def __init__(self, user_name, password):
        policy = Policy(query_interval=1)
        super(CsdnProvider, self).__init__("http://blog.csdn.net/%s/services/metablogapi.aspx"%user_name, user_name, password, only_summary_in_recent_posts= True, policy = policy)

class SinaProvider(metaweblog.MetaWeblogProvider):
    #http://upload.move.blog.sina.com.cn/blog_rebuild/blog/xmlrpc.php
    def __init__(self, user_name, password):
        super(SinaProvider, self).__init__("http://upload.move.blog.sina.com.cn/blog_rebuild/blog/xmlrpc.php", user_name, password)

class NeteaseProvider(metaweblog.MetaWeblogProvider):
    def __init__(self, user_name, password):
        super(SinaProvider, self).__init__("http://os.blog.163.com/api/xmlrpc/metaweblog", user_name, password)

class NeteaseProvider(metaweblog.MetaWeblogProvider):
    def __init__(self, user_name, password):
        super(NeteaseProvider, self).__init__("http://os.blog.163.com/api/xmlrpc/metaweblog/", user_name, password)
